/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.Interactions.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import uimigration.Interactions.Action;
import uimigration.Interactions.Behaviour;
import uimigration.Interactions.InteractionsPackage;
import uimigration.Plateform.Device;
import uimigration.mappingmodel.ActionType;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Action</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.Interactions.impl.ActionImpl#getIdAction <em>Id Action</em>}</li>
 *   <li>{@link uimigration.Interactions.impl.ActionImpl#getName <em>Name</em>}</li>
 *   <li>{@link uimigration.Interactions.impl.ActionImpl#getComposedActions <em>Composed Actions</em>}</li>
 *   <li>{@link uimigration.Interactions.impl.ActionImpl#getType <em>Type</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class ActionImpl extends InputImpl implements Action {
	/**
	 * The default value of the '{@link #getIdAction() <em>Id Action</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIdAction()
	 * @generated
	 * @ordered
	 */
	protected static final int ID_ACTION_EDEFAULT = 0;
	/**
	 * The cached value of the '{@link #getIdAction() <em>Id Action</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIdAction()
	 * @generated
	 * @ordered
	 */
	protected int idAction = ID_ACTION_EDEFAULT;
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;
	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;
	/**
	 * The cached value of the '{@link #getComposedActions() <em>Composed Actions</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getComposedActions()
	 * @generated
	 * @ordered
	 */
	protected Action composedActions;
	/**
	 * The default value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected static final ActionType TYPE_EDEFAULT = ActionType.SPACE;
	/**
	 * The cached value of the '{@link #getType() <em>Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getType()
	 * @generated
	 * @ordered
	 */
	protected ActionType type = TYPE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return InteractionsPackage.Literals.ACTION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getIdAction() {
		return idAction;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIdAction(int newIdAction) {
		int oldIdAction = idAction;
		idAction = newIdAction;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InteractionsPackage.ACTION__ID_ACTION, oldIdAction, idAction));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InteractionsPackage.ACTION__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Action getComposedActions() {
		if (composedActions != null && composedActions.eIsProxy()) {
			InternalEObject oldComposedActions = (InternalEObject)composedActions;
			composedActions = (Action)eResolveProxy(oldComposedActions);
			if (composedActions != oldComposedActions) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, InteractionsPackage.ACTION__COMPOSED_ACTIONS, oldComposedActions, composedActions));
			}
		}
		return composedActions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Action basicGetComposedActions() {
		return composedActions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setComposedActions(Action newComposedActions) {
		Action oldComposedActions = composedActions;
		composedActions = newComposedActions;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InteractionsPackage.ACTION__COMPOSED_ACTIONS, oldComposedActions, composedActions));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActionType getType() {
		return type;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setType(ActionType newType) {
		ActionType oldType = type;
		type = newType == null ? TYPE_EDEFAULT : newType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InteractionsPackage.ACTION__TYPE, oldType, type));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public void fire(Behaviour behavior, Device device) {
		behavior.trigger(device);
		throw new UnsupportedOperationException();

	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case InteractionsPackage.ACTION__ID_ACTION:
				return getIdAction();
			case InteractionsPackage.ACTION__NAME:
				return getName();
			case InteractionsPackage.ACTION__COMPOSED_ACTIONS:
				if (resolve) return getComposedActions();
				return basicGetComposedActions();
			case InteractionsPackage.ACTION__TYPE:
				return getType();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case InteractionsPackage.ACTION__ID_ACTION:
				setIdAction((Integer)newValue);
				return;
			case InteractionsPackage.ACTION__NAME:
				setName((String)newValue);
				return;
			case InteractionsPackage.ACTION__COMPOSED_ACTIONS:
				setComposedActions((Action)newValue);
				return;
			case InteractionsPackage.ACTION__TYPE:
				setType((ActionType)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case InteractionsPackage.ACTION__ID_ACTION:
				setIdAction(ID_ACTION_EDEFAULT);
				return;
			case InteractionsPackage.ACTION__NAME:
				setName(NAME_EDEFAULT);
				return;
			case InteractionsPackage.ACTION__COMPOSED_ACTIONS:
				setComposedActions((Action)null);
				return;
			case InteractionsPackage.ACTION__TYPE:
				setType(TYPE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case InteractionsPackage.ACTION__ID_ACTION:
				return idAction != ID_ACTION_EDEFAULT;
			case InteractionsPackage.ACTION__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case InteractionsPackage.ACTION__COMPOSED_ACTIONS:
				return composedActions != null;
			case InteractionsPackage.ACTION__TYPE:
				return type != TYPE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (idAction: ");
		result.append(idAction);
		result.append(", name: ");
		result.append(name);
		result.append(", type: ");
		result.append(type);
		result.append(')');
		return result.toString();
	}

} //ActionImpl
